import api from '../../api';
import { message } from 'antd';

export default {
  namespace: 'trailM', //试算
  state: {},
  effects: {
    //试算
    *trialData({ payload, callback }, { call, put }) {
      const response = yield call(api.trialData, payload);
      if (response && response?.code == 0) {
        callback(response.data);
      } else {
        callback();
        message.error(response?.msg);
      }
    },
    //债券簿记试算时获取全价
    *trialfullPrice({ payload, callback }, { call, put }) {
      const response = yield call(api.trialfullPrice, payload);
      if (response) {
        callback(response);
      } else {
        callback();
        message.error('获取全价失败');
      }
    },
  },

  reducers: {
    save(state, { payload }) {
      return { ...state, ...payload };
    },
  },
};
